<?php
namespace core\database\driver;

use core\database\IDatabase;

class PDO implements IDatabase
{
	/**
	 * @var \PDO
	 */
	private $link;

	function __construct($host, $user, $pass, $dbname)
	{
		$this->connect($host, $user, $pass, $dbname);
		return $this->link;
	}

	function connect($host, $user, $pass, $dbname)
	{
		$db = new \PDO("mysql:{$host};dbname={$dbname}", $user, $pass);
		$this->link = $db;
	}

	function query($sql)
	{
		return $this->link->query($sql);
	}

	function close()
	{
		unset($this->link);
	}
}
